from selenium import webdriver
import time
from selenium.webdriver.common.by import By

# 打开谷歌浏览器,打开so搜索首页


driver = webdriver.Chrome()
driver.get('https://www.so.com/')

# 搜索框输入'python自动化测试',点击搜索
input = driver.find_element(By.ID, 'input')
input.send_keys('python自动化测试')

button = driver.find_element(By.ID,'search-button')
button.click()

# 获取标题
time.sleep(3)
title = driver.title
print(title)

# 判断'python'关键字是否在标题中

if 'python' in title:
    print('找到了')
else:
    print('没找到')

# 关闭谷歌浏览器
time.sleep(2)
driver.quit()
